#!/usr/bin/e    nv python
# coding: utf-8

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util

import module.search
import datetime

class MainHandler(webapp.RequestHandler):
    def get(self):
        product_list = module.search.SearchProducts.get_product(None, 0)
        today = datetime.datetime.now()
        for p in product_list:
            if p.time_end < today:
                p.is_expired = 1
                p.put()

def main():
    application = webapp.WSGIApplication([('/update_expired', MainHandler)],
                                         debug=True)
    util.run_wsgi_app(application)

if __name__ == '__main__':
    main()